(function ($) {
    $.fn.zhyslide = function (option) {
        var defaults = {
            speed: 2000,
            event: 'mouseenter'
        }
        var settings = $.extend(defaults, option);
        var $box = this;
        var los = $box.find('.lunbo').children();
        var rou = $box.find('.round').children();

        function show() {
            los.eq(index).fadeIn(400).siblings().fadeOut(400);
            rou.eq(index).addClass('active')
                .siblings().removeClass('active');
        }
        var index = 0;
        function nextImg() {
            index = index == los.length - 1 ? 0 : index + 1;
            show();
        }
        function prevImg() {
            index = index == 0 ? los.length - 1 : index - 1;
            show();
        }
        if (settings.speed > 0) {
            var timer = setInterval(nextImg, settings.speed);
            $box.hover(function () {
                clearInterval(timer);
                timer = null;
            }, function () {
                if (timer) return;
                timer = setInterval(nextImg, settings.speed);
            });
        }
        rou.on(settings.event, function () {
            index = $(this).index();
            show();
        }); $box.find('.prev').click(function () {
            prevImg();
        })
        $box.find('.next').click(function () {
            nextImg();
        })
    }
})(jQuery)